// 表单配置
let formConfig = [{
  label: '商品名称：',
  prop: 'productName',
  type: 'input',
  width: '150px'
}, {
  label: '商品品牌：',
  prop: 'brand',
  type: 'select',
  width: '150px',
  options: []
}, {
  label: '上架/下架：',
  prop: 'status',
  type: 'select',
  width: '150px',
  options: [{
    label: '上架商品',
    value: '1'
  }, {
    label: '下架商品',
    value: '0'
  }]
}
]
// -----------------
let productListData = []
import AgriculturalSortManagement from '@/api/module/agricultural-sort-management'

function deWeightThree (arr) {
  let map = new Map();
  for (let item of arr) {
    if (!map.has(item.value)) {
      map.set(item.value, item);
    }
  }
  return [...map.values()];
}
function queryProductList () {
  let productList = []
  AgriculturalSortManagement.queryByCondition({}).then(res => {
    console.log(res.data)
    if (res.data && res.data.length > 0) {
      res.data.forEach(item => {
        productList.push({
          label: item.brand,
          value: item.brand
        })
        productList = deWeightThree(productList)
      })
    }

    formConfig.forEach(item => {
      if (item.label == "商品品牌：") {
        item.options = productList
      }
    })
    productListData = productList
  })
};
queryProductList();
export { formConfig, productListData }